import { getUserList, deleteUserById,addUser } from '../pages/User/server'

export function getUserLIst() {
  return dispatch => {
    getUserList()
      .then(userList => {
        dispatch(sevaUserList(userList))
      })

  }
}

export function sevaUserList(userList) {
  return {
    type: "GET_USER_LIST",
    userList
  }
}

// 根据id删除用户
export function deleteUser(id) {
  return dispatch => {
    deleteUserById(id)
      .then(userList => {
        dispatch({
          type: "DELETE_USER",
          userList
        })
      })
  }
}

// 
export function addUserAction(user){
  return dispatch=>{
    addUser(user)
     .then(userList=>{
       dispatch({
         type:"ADD_USER",
         userList
       })
     })
  }
}




